#!/usr/bin/env python
from utils import WSGIServerLog

class WebServer(WSGIServerLog):
	import os
	os.environ['DJANGO_SETTINGS_MODULE'] = 'gmultiserver.dj.settings'
	def __init__(self, address = '', port = 8088):
		from django.core.handlers.wsgi import WSGIHandler
		from django.core.management import call_command
		from django.core.signals import got_request_exception
		def exception_printer(sender, **kwargs):
			self._log(**kwargs)
		got_request_exception.connect(exception_printer)
		call_command('syncdb')
		WSGIServerLog.__init__(self, (address, port), WSGIHandler())
		self.handler_class.name = 'web'
